Skip to main content

API Test Actions

DevAssure supports a range of actions specifically designed for API testing. These actions enable you to interact with APIs, verify responses, and extract data from API calls, enhancing your automated testing capabilities.

ActionDescription
Call API (api)Initiates a call to the specified API.
Verify Status Code of (http response)Checks if the status code of the HTTP response matches the expected value.
Verify Text of (http response)Verifies if the text content of the HTTP response matches the expected text.
Verify JSON Body of (http response)Checks if the JSON body of the HTTP response matches the expected JSON structure or content.
Get Status Code of (http response)Retrieves the status code from the HTTP response.
Get Body Text of (http response)Retrieves the text content from the body of the HTTP response.
Get JSON Body of (http response)Retrieves the JSON body from the HTTP response.
Get Headers of (http response)Retrieves all headers from the HTTP response.
Get Header Value of (http response) with (key)Retrieves the value of a specific header from the HTTP response based on the provided key.

Call API (api)

Initiates a call to the specified API.
  • Usage:

    apiResponse = Call API apidemo > employee
  • Arguments:

    • api: The API endpoint to be called , which will be created as API Request and invoked in the test action.
  • Returns:

    • apiResponse of the specified call.

Verify Status Code of (http response) (comparator) (expected)

Checks if the status code of the HTTP response matches the expected value.
  • Usage:

    Verify status code of http response apiResponse == 200
  • Arguments:

    • http response: The HTTP response from the API call.
    • comparator: A comparison method used to verify the status code of http response.
  • Returns:

    • Boolean. Returns true if the status code matches, otherwise false.

Verify Text of (http response)

Verifies if the text content of the HTTP response matches the expected text.
  • Usage:

    Verify text of http response apiResponse equals expected response text
  • Arguments:

    • http response: The HTTP response from the API call.
  • Returns:

    • Boolean. Returns true if the text matches, otherwise false.

Verify JSON Body of (http response) (Json key) (comparator) (expected)

Checks if a specific value within the JSON body of the HTTP response matches the expected value using the provided comparator.
  • Usage:

    Verify Json body of http response apiResponse name equals John Doe
  • Arguments:

    • http response: The HTTP response from the API call.
    • Json key: The key within the JSON body whose value you want to verify.
    • comparator: A comparison method ( equals, not equals) used to verify the http response.
    • expected: The expected value to compare against the actual value extracted from the JSON body using the Json key.
  • Returns:

    • Boolean. Returns true if the value matches the expected value according to the specified comparator, otherwise false.

Get Status Code of (http response)

Retrieves the status code from the HTTP response.
  • Usage:

    status = Get status code of http response apiResponse
  • Arguments:

    • The status code of the response.

Get Body Text of (http response)

Retrieves the text content from the body of the HTTP response.
  • Usage:

    text = Get body text of http response apiResponse
  • Arguments:

    • http response: The HTTP response from the API call.
  • Returns:

    • The text content of the response body.

Get JSON Body of (http response)

Simulates a left-click action on the specified element, in the page under test.
  • Usage:

    jsonBody = Get Json body of http response apiResponse
    Print log ${JSON.stringify(jsonBody)}

  • Arguments:

    • http response: The HTTP response from the API call.
  • Returns: JSON Object. The JSON content of the response body.

Get Headers of (http response)

Retrieves all headers from the HTTP response.
  • Usage:
    headers = Get Headers of http response apiResponse
  • Arguments:

    • http response: The HTTP response from the API call.
  • Returns: An object containing all headers as key-value pairs.

Get Header Value of (http response) with (key)

Retrieves the value of a specific header from the HTTP response based on the provided key.
  • Usage:

    headerValue = Get Header value of http response apiResponse with key name
  • Arguments:

    • http response: The HTTP response from the API call.
    • key: The key of the header whose value is to be retrieved.